from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By


def get_chrome():
    options = Options()
    options.add_argument('--no-sandbox')
    options.add_argument('disable-infobars')
    # options.add_argument("--auto-open-devtools-for-tabs")
    options.add_experimental_option('excludeSwitches', ['enable-automation'])
    options.add_experimental_option('detach', True)

    driver_path = "D:\\Software\\Chrome\\chromedriver-win64\\chromedriver.exe"
    service = Service(driver_path)
    return webdriver.Chrome(service=service, options=options)


if __name__ == '__main__':
    chrome = get_chrome()
    # 打开指定的网页，标签页
    chrome.get("https://docs.qq.com/sheet/DYm5idEhMaEt3S2ha?tab=uba9qp")
    chrome.maximize_window()
    # time.sleep(3)
    # chrome.minimize_window()
    # chrome.set_window_position(0, 0)
    # chrome.set_window_size(100, 100)
    # chrome.get_screenshot_as_file("D:\\Software\\Chrome\\chromedriver-win64\\screenshot.png")
    # chrome.refresh()

    # main_menu = chrome.find_element(By.CLASS_NAME, "main-menu-file")
    # print(main_menu)
